home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / animImportOptions.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  14.1 KB  |  525 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. global proc int animImportOptions ( string $parent, 
  18.                                     string $action,
  19.                                     string $initialSettings, 
  20.                                     string $resultCallback )
  21. //
  22. //    Description:
  23. //        This script posts the anim file accessor options.
  24. //
  25. //    Parameters:
  26. //        $parent    - the elf parent layout for this options layout. It is
  27. //                    always a scrollLayout.
  28. //        $action    - the action that is to be performed with this invokation
  29. //                    of this proc. Valid options are:
  30. //                        "query" - construct the options string and pass it
  31. //                                    to the resultCallback.
  32. //                        "post"    - post all the elf controls.
  33. //        $resultCallback    -
  34. //                This is the proc to be called with the result string. 
  35. //                resultCallback ( string $optionsString )
  36. //
  37. //    Returns:
  38. //        1 if successfull.
  39. //        0 otherwise.
  40. //
  41. {
  42.     int     $result;
  43.     string     $currentOptions;
  44.     string     $optionList[];
  45.     string     $optionBreakDown[];
  46.     int        $index;
  47.     
  48.     if ($action == "post") {
  49.         setUITemplate -pushTemplate DefaultTemplate;
  50.         setParent $parent;
  51.  
  52.         columnLayout -adj true animMultiObjCol;
  53.     
  54.             radioButtonGrp
  55.                 -numberOfRadioButtons 4
  56.                 -label "Time Range"
  57.                 -label1 "Start"
  58.                 -cc1 ("floatFieldGrp -e -enable true animStartTime; " +
  59.                       "floatFieldGrp -e -enable false animEndTime; " +
  60.                       "updateAnimImportOptionsEnable;")
  61.                 -label2 "Start/End"
  62.                 -cc2 ("floatFieldGrp -e -enable true animStartTime; " +
  63.                       "floatFieldGrp -e -enable true animEndTime; " +
  64.                       "updateAnimImportOptionsEnable;")
  65.                 -label3 "Current" 
  66.                 -cc3 ("floatFieldGrp -e -enable false animStartTime; " +
  67.                       "floatFieldGrp -e -enable false animEndTime; " +
  68.                       "updateAnimImportOptionsEnable;")
  69.                 -label4 "Clipboard" 
  70.                 -cc4 ("floatFieldGrp -e -enable false animStartTime; " +
  71.                       "floatFieldGrp -e -enable false animEndTime; " +
  72.                       "updateAnimImportOptionsEnable;")
  73.                 animTimeRange;
  74.             
  75.             floatFieldGrp -label "Start Time" -value1 0.0 animStartTime;
  76.             floatFieldGrp -label "End Time" -value1 10.0 animEndTime;
  77.             
  78.             intSliderGrp -label "Copies" -field true -min 1 -value 1 animCopies;
  79.  
  80.             separator -style "in" -w 1000;
  81.             
  82.             checkBoxGrp -label "Help Images" -ncb 1 -value1 off -l1 "" 
  83.                 -cc1 "animImportHelpPictures;" 
  84.                 animHelpPictures;
  85.             
  86.             radioButtonGrp
  87.                 -numberOfRadioButtons 3
  88.                 -label "Clipboard Adjustment"
  89.                 -label1 "Preserve" -cc1 "updateAnimImportOptionsEnable"
  90.                 -label2 "Scale" -cc2 "updateAnimImportOptionsEnable"
  91.                 -label3 "Fit" -cc3 "updateAnimImportOptionsEnable"
  92.                 animAdjustment;
  93.             
  94.             radioButtonGrp
  95.                 -numberOfRadioButtons 3
  96.                 -label "Paste Method"
  97.                 -label1 "Insert" -cc1 "updateAnimImportOptionsEnable"
  98.                 -label2 "Replace" -cc2 "updateAnimImportOptionsEnable"
  99.                 -label3 "Merge" -cc3 "updateAnimImportOptionsEnable"
  100.                 animMethod;
  101.  
  102.             radioButtonGrp
  103.                 -numberOfRadioButtons 2
  104.                 -label "Replace Region"
  105.                 -label1 "Time Range" -cc1 "updateAnimImportOptionsEnable"
  106.                 -label2 "Entire Curve" -cc2 "updateAnimImportOptionsEnable"
  107.                 animReplace;
  108.  
  109.             checkBoxGrp    -label "Connect" 
  110.                         -label1 "" -cc1 "animImportHelpPictures" animConnect;
  111.  
  112.             columnLayout -columnAttach "left" 10;
  113.                 picture animHelpPicture;
  114.  
  115.  
  116.         // Now set to current settings.
  117.         //
  118.         $currentOptions = $initialSettings;
  119.         if (size($currentOptions) > 0) {
  120.             tokenize($currentOptions, ";", $optionList);
  121.             for ($index = 0; $index < size($optionList); $index++) {
  122.                 tokenize($optionList[$index], "=", $optionBreakDown);
  123.  
  124.                 if ($optionBreakDown[0] == "targetTime") {
  125.  
  126.                     int $whichTime = $optionBreakDown[1];
  127.                     radioButtonGrp -edit -select $whichTime animTimeRange;
  128.                     floatFieldGrp -e -enable 
  129.                         ($whichTime == 1 || $whichTime == 2) animStartTime;
  130.                     floatFieldGrp -e -enable ($whichTime == 2) animEndTime;
  131.  
  132.                 } else if ($optionBreakDown[0] == "time") {
  133.  
  134.                     string $time = $optionBreakDown[1];
  135.                     string $range[];
  136.                     tokenize ($time, ":", $range);
  137.  
  138.                     // Only one time
  139.                     //
  140.                     if( size( $range ) == 1 ) {
  141.                         floatFieldGrp     -edit -value1 
  142.                                         (float( $range[0] )) animStartTime;
  143.                         floatFieldGrp     -edit -value1 
  144.                                         (float( $range[0] )) animEndTime;
  145.                     }
  146.                     // A time range
  147.                     //
  148.                     else if( size( $range ) > 1 ) {
  149.                         floatFieldGrp     -edit -value1 
  150.                                         (float( $range[0] )) animStartTime;
  151.                         floatFieldGrp     -edit -value1 
  152.                                         (float( $range[1] )) animEndTime;
  153.                     }
  154.  
  155.                 } else if ($optionBreakDown[0] == "copies") {
  156.                     int $copies = $optionBreakDown[1];
  157.                     intSliderGrp -e -value $copies animCopies;
  158.                 } else if ($optionBreakDown[0] == "option") {
  159.                     string $option = $optionBreakDown[1];
  160.  
  161.                     // pasteInsert
  162.                     //
  163.                     if ($option == "insert") {
  164.                         radioButtonGrp
  165.                             -edit
  166.                             -select 1
  167.                             animAdjustment;
  168.                         radioButtonGrp
  169.                             -edit
  170.                             -select 1
  171.                             animMethod;
  172.                         radioButtonGrp
  173.                             -edit
  174.                             -select 1
  175.                             animReplace;
  176.                     }
  177.                     // scaleInsert
  178.                     else if ($option == "scaleInsert") {
  179.                         radioButtonGrp
  180.                             -edit
  181.                             -select 2
  182.                             animAdjustment;
  183.                         radioButtonGrp
  184.                             -edit
  185.                             -select 1
  186.                             animMethod;
  187.                         radioButtonGrp
  188.                             -edit
  189.                             -select 1
  190.                             animReplace;
  191.                     }
  192.                     // fitInsert
  193.                     else if ($option == "fitInsert") {
  194.                         radioButtonGrp
  195.                             -edit
  196.                             -select 3
  197.                             animAdjustment;
  198.                         radioButtonGrp
  199.                             -edit
  200.                             -select 1
  201.                             animMethod;
  202.                         radioButtonGrp
  203.                             -edit
  204.                             -select 1
  205.                             animReplace;
  206.                     }
  207.                     // replace
  208.                     else if ($option == "replace") {
  209.                         radioButtonGrp
  210.                             -edit
  211.                             -select 1
  212.                             animAdjustment;
  213.                         radioButtonGrp
  214.                             -edit
  215.                             -select 2
  216.                             animMethod;
  217.                         radioButtonGrp
  218.                             -edit
  219.                             -select 1
  220.                             animReplace;
  221.                     }
  222.                     // replaceCompletely
  223.                     else if ($option == "replaceCompletely") {
  224.                         radioButtonGrp
  225.                             -edit
  226.                             -select 1
  227.                             animAdjustment;
  228.                         radioButtonGrp
  229.                             -edit
  230.                             -select 2
  231.                             animMethod;
  232.                         radioButtonGrp
  233.                             -edit
  234.                             -select 2
  235.                             animReplace;
  236.                     }
  237.                     // scaleReplace
  238.                     else if ($option == "scaleReplace") {
  239.                         radioButtonGrp
  240.                             -edit
  241.                             -select 2
  242.                             animAdjustment;
  243.                         radioButtonGrp
  244.                             -edit
  245.                             -select 2
  246.                             animMethod;
  247.                         radioButtonGrp
  248.                             -edit
  249.                             -select 1
  250.                             animReplace;
  251.                     }
  252.                     // fitReplace
  253.                     else if ($option == "fitReplace") {
  254.                         radioButtonGrp
  255.                             -edit
  256.                             -select 3
  257.                             animAdjustment;
  258.                         radioButtonGrp
  259.                             -edit
  260.                             -select 2
  261.                             animMethod;
  262.                         radioButtonGrp
  263.                             -edit
  264.                             -select 1
  265.                             animReplace;
  266.                     }
  267.                     // pasteMerge
  268.                     else if ($option == "merge") {
  269.                         radioButtonGrp
  270.                             -edit
  271.                             -select 1
  272.                             animAdjustment;
  273.                         radioButtonGrp
  274.                             -edit
  275.                             -select 3
  276.                             animMethod;
  277.                         radioButtonGrp
  278.                             -edit
  279.                             -select 1
  280.                             animReplace;
  281.                     }
  282.                     // scaleMerge
  283.                     else if ($option == "scaleMerge") {
  284.                         radioButtonGrp
  285.                             -edit
  286.                             -select 2
  287.                             animAdjustment;
  288.                         radioButtonGrp
  289.                             -edit
  290.                             -select 3
  291.                             animMethod;
  292.                         radioButtonGrp
  293.                             -edit
  294.                             -select 1
  295.                             animReplace;
  296.                     }
  297.                     // fitMerge
  298.                     else if( $option == "fitMerge" ) {
  299.                         radioButtonGrp
  300.                             -edit
  301.                             -select 3
  302.                             animAdjustment;
  303.                         radioButtonGrp
  304.                             -edit
  305.                             -select 3
  306.                             animMethod;
  307.                         radioButtonGrp
  308.                             -edit
  309.                             -select 1
  310.                             animReplace;
  311.                     }
  312.                 
  313.                 } else if ($optionBreakDown[0] == "pictures") {
  314.                     int $picture = $optionBreakDown[1];
  315.                     checkBoxGrp -e -value1 $picture animHelpPictures;
  316.                 } else if ($optionBreakDown[0] == "copies") {
  317.                     int $connect = $optionBreakDown[1];
  318.                     checkBoxGrp -e -value1 $connect animConnect;
  319.                 }
  320.             }
  321.         }
  322.  
  323.         updateAnimImportOptionsEnable();
  324.  
  325.         setUITemplate -popTemplate;
  326.         $result = 1;
  327.     } else if ($action == "query") {
  328.         $currentOptions += ";";
  329.         $currentOptions += 
  330.             ("targetTime=" + `radioButtonGrp -query -select animTimeRange`);
  331.         $currentOptions += ";";
  332.  
  333.         int $whichTime = `radioButtonGrp -query -select animTimeRange`;
  334.         if ($whichTime == 1) {
  335.             $currentOptions += 
  336.                     ("time=" + 
  337.                     string (`floatFieldGrp -query -value1 animStartTime`));
  338.             $currentOptions += ";";
  339.         } else if ($whichTime == 2) {
  340.             $currentOptions += ("time=" + 
  341.                 string (`floatFieldGrp -query -value1 animStartTime`) +    
  342.                 ":" + string(`floatFieldGrp -query -value1 animEndTime`));
  343.             $currentOptions += ";";
  344.         } else if ($whichTime == 3) {
  345.             $currentOptions += ("time="+`currentTime -q`);
  346.             $currentOptions += ";";
  347.         }
  348.     
  349.         $currentOptions += 
  350.             ("copies=" + `intSliderGrp -query -value animCopies`);
  351.         $currentOptions += ";";
  352.  
  353.         string $option = "";
  354.         int $selected = `radioButtonGrp -query -select animAdjustment`;
  355.         if ($selected == 2) {
  356.             $option = "scale";
  357.         } else if ($selected == 3) {
  358.             $option = "fit";
  359.         }
  360.  
  361.         $selected = `radioButtonGrp -query -select animMethod`;
  362.         if ($selected == 1) {
  363.             if ($option == "") {
  364.                 $option += "insert";
  365.             } else {
  366.                 $option += "Insert";
  367.             }
  368.         } else if ($selected == 2) {
  369.             if ($option == "") {
  370.                 $option += "replace";
  371.             } else {
  372.                 $option += "Replace";
  373.             }
  374.  
  375.             if(`radioButtonGrp -query -select animReplace` == 2) {
  376.                 $option += "Completely";
  377.             }
  378.         } else if ($selected == 3) {
  379.             if ($option == "") {
  380.                 $option += "merge";
  381.             } else {
  382.                 $option += "Merge";
  383.             }
  384.         }
  385.  
  386.         $currentOptions += ("option=" + $option);
  387.         $currentOptions += ";";
  388.  
  389.         $currentOptions += 
  390.             ("pictures=" + `checkBoxGrp -query -value1 animHelpPictures`);
  391.         $currentOptions += ";";
  392.  
  393.         $currentOptions += ("connect=" + `checkBoxGrp -q -value1 animConnect`);
  394.         $currentOptions += ";";
  395.  
  396.         eval($resultCallback+" \""+$currentOptions+"\"");
  397.         $result = 1;
  398.     } else {
  399.         $result = 0;
  400.     }
  401.  
  402.     return $result;
  403. }
  404.  
  405. global proc animImportHelpPictures() 
  406. {
  407.     int $doPictures = `checkBoxGrp -q -value1 animHelpPictures`;
  408.     if( $doPictures == 0 ) {
  409.         picture -e -visible no animHelpPicture;
  410.         return;
  411.     }
  412.  
  413.     int $adjustment = `radioButtonGrp -q -select animAdjustment`;
  414.     int $method = `radioButtonGrp -q -select animMethod`;
  415.     int $connect = `checkBoxGrp -q -value1 animConnect`;
  416.     int $isFromClipboard = (`radioButtonGrp -q -select animTimeRange` == 4);
  417.  
  418.     string $helpPicture = "CCPpaste";
  419.  
  420.     if($adjustment == 1) {
  421.         if($isFromClipboard) {
  422.             $helpPicture += "Clip";
  423.         } else {
  424.             $helpPicture += "Preserve";
  425.         }
  426.     } else if ($adjustment == 2) {
  427.         $helpPicture += "Scale";
  428.     } else {
  429.         $helpPicture += "Fit";
  430.     }
  431.         
  432.     if ($method == 1) {
  433.         $helpPicture += "Insert";
  434.     } else if ($method == 2) {
  435.         $helpPicture += "Replace";
  436.         if($isFromClipboard) {
  437.             if(`radioButtonGrp -query -select animReplace` == 2) {
  438.                 $helpPicture += "Complete";
  439.             } else {
  440.                 $helpPicture += "Range";
  441.             }
  442.         }
  443.     } else {
  444.         $helpPicture += "Merge";
  445.     }
  446.  
  447.     if (($connect == 1 ) && ( `checkBoxGrp -q -enable animConnect`)) {
  448.         $helpPicture += "Connect";
  449.     }
  450.  
  451.     $helpPicture += ".xpm";
  452.  
  453.     picture -e -image $helpPicture -visible yes animHelpPicture;
  454. }
  455.  
  456. global proc updateAnimImportOptionsEnable() {
  457.     int $whichTimeRange = `radioButtonGrp -q -select animTimeRange`;
  458.     int $isTimeRange = ($whichTimeRange == 2);
  459.  
  460.     // enable the ones that can accept time ranges
  461.     //
  462.     if($isTimeRange) {
  463.         int $isPreserve = (`radioButtonGrp -q -select animAdjustment` == 1);
  464.  
  465.         radioButtonGrp -e -enable1 ( !$isTimeRange ) animAdjustment;
  466.         radioButtonGrp -e -enable2 yes animAdjustment;
  467.         radioButtonGrp -e -enable3 yes animAdjustment;
  468.  
  469.         // If we've disabled the "Preserve" option but it was selected,
  470.         // select "Fit" instead.
  471.         //
  472.         if( $isPreserve && $isTimeRange ) {
  473.             $isPreserve = false;
  474.             radioButtonGrp -e -select 3 animAdjustment;
  475.         }
  476.  
  477.         radioButtonGrp -e -enable1 (!$isPreserve) animMethod;
  478.         radioButtonGrp -e -enable2 yes animMethod;
  479.         radioButtonGrp -e -enable3 (!$isPreserve) animMethod;
  480.  
  481.         if( $isPreserve ) {
  482.             radioButtonGrp -e -select 2 animMethod;
  483.         }
  484.     }
  485.     // disable the ones that can't accept time ranges
  486.     //
  487.     else {
  488.         int $isFromClipboard = (`radioButtonGrp -q -select animTimeRange` == 4);
  489.  
  490.         radioButtonGrp -e -enable1 yes -select 1 animAdjustment;
  491.         radioButtonGrp -e -enable2 no  animAdjustment;
  492.         radioButtonGrp -e -enable3 no  animAdjustment;
  493.  
  494.         radioButtonGrp -e -enable1 yes animMethod;
  495.         radioButtonGrp -e -enable2 $isFromClipboard  animMethod;
  496.         radioButtonGrp -e -enable3 yes animMethod;
  497.  
  498.         if(( $whichTimeRange != 0 )
  499.         && ( !$isFromClipboard ) 
  500.         && ( `radioButtonGrp -q -select animMethod` == 2 )) 
  501.         {
  502.             radioButtonGrp -e -select 1 animMethod;
  503.         }
  504.     }
  505.  
  506.     // The replace option is enabled if the replace method is selected.
  507.     //
  508.     int $isReplaceMethod = (`radioButtonGrp -q -select animMethod` == 2);
  509.     int $enableReplaceCurve = ( !$isTimeRange && $isReplaceMethod );
  510.  
  511.     radioButtonGrp -e -enable $isReplaceMethod animReplace;
  512.     radioButtonGrp -e -enable2 $enableReplaceCurve animReplace;
  513.  
  514.     if( !$enableReplaceCurve && (`radioButtonGrp -q -select animReplace` == 2) ) {
  515.         radioButtonGrp -e -select 1 animReplace;
  516.     }
  517.  
  518.     // The connect option is only enabled when the method is NOT "Merge"
  519.     //
  520.     checkBoxGrp -edit -enable 
  521.                 (`radioButtonGrp -q -select animMethod` != 3) animConnect;
  522.  
  523.     animImportHelpPictures;
  524. }
  525.